﻿#include "saveimgworker.h"
#include <QDir>
#include <QDebug>
SaveImgWorker::SaveImgWorker(QObject *parent) : QObject(parent)
{

}



SaveImgWorker::~SaveImgWorker()
{

}
void SaveImgWorker::Initialize()
{

}

void SaveImgWorker::start(CameraData m_cImageInfo)
{
    qDebug() << " SaveImgWorker:"<< m_cImageInfo.m_nNGorOK;
    QString strPath = QDir::currentPath() + "/Pic";
    switch (m_cImageInfo.m_nIndex) {
    case 1:
        strPath += "/ccd1";
        break;
    case 2:
        strPath += "/ccd2";
        break;
    case 3:
        strPath += "/ccd3";
        break;
    case 4:
        strPath += "/ccd4";
        break;
    }
    switch (m_cImageInfo.m_nNGorOK) {
    case 0:
        strPath += "/OK/";
        break;
    case 1:case 10:case 11:
        strPath += "/NG/";
        break;
    default:
        strPath += "/Abnormal/";
        break;
    }
    QString path = QString("%1%2.bmp").arg(strPath).arg(m_nIndex);
    HalconCpp::WriteImage(m_cImageInfo.Hobj,"bmp",0,path.toStdString().c_str());
    m_nIndex ++;
}

